/*
package service;

import dao.ManagerDao;
import domain.Manager;
import thread.SocketRunable;

import java.io.*;
import java.net.Socket;
import java.util.ArrayList;

public class ManagerService extends SocketRunable {
    ManagerDao dao = new ManagerDao();
    private Socket socket;

    public ManagerService(Socket socket) {
        super(socket);
    }

    @Override
    public void run() {
        try {
            //解析客户端的请求数据,来匹配对应的操作
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String s = br.readLine();
            System.out.println("本次客户端请求的数据为:" + s);
            String option = s.substring(0, 3);
            String data = s.substring(3);
            String[] split = data.split(",");
            String name = split[0];
            String passWord = split[1];

            if (option.equals("[0]")) {
                login(name, passWord);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void login(String name, String passWord) throws IOException {
        ArrayList<Manager> man = dao.login();
        boolean flag = false;
        for (Manager everyMan : man) {
            if (everyMan.getName().equals(name) && everyMan.getPassWord().equals(passWord)) {
                flag = true;
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        if (flag) {
            bw.write("true");
        } else {
            bw.write("false");
        }
        bw.newLine();
        bw.flush();
        bw.close();
        socket.close();
    }
}
*/
